/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package warmachinesystem.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

import warmachinesystem.BaseUnit;
import warmachinesystem.TierLevel;
import warmachinesystem.TierList;
import warmachinesystem.Warcaster;
import warmachinesystem.WarmachineSystemPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Tier List</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link warmachinesystem.impl.TierListImpl#getWarcaster <em>Warcaster</em>}</li>
 *   <li>{@link warmachinesystem.impl.TierListImpl#getLevels <em>Levels</em>}</li>
 *   <li>{@link warmachinesystem.impl.TierListImpl#getAllowedUnits <em>Allowed Units</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TierListImpl extends EObjectImpl implements TierList {
	/**
	 * The cached value of the '{@link #getWarcaster() <em>Warcaster</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWarcaster()
	 * @generated
	 * @ordered
	 */
	protected Warcaster warcaster;

	/**
	 * The cached value of the '{@link #getLevels() <em>Levels</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLevels()
	 * @generated
	 * @ordered
	 */
	protected EList<TierLevel> levels;

	/**
	 * The cached value of the '{@link #getAllowedUnits() <em>Allowed Units</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAllowedUnits()
	 * @generated
	 * @ordered
	 */
	protected EList<BaseUnit> allowedUnits;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TierListImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return WarmachineSystemPackage.Literals.TIER_LIST;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Warcaster getWarcaster() {
		if (warcaster != null && warcaster.eIsProxy()) {
			InternalEObject oldWarcaster = (InternalEObject)warcaster;
			warcaster = (Warcaster)eResolveProxy(oldWarcaster);
			if (warcaster != oldWarcaster) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WarmachineSystemPackage.TIER_LIST__WARCASTER, oldWarcaster, warcaster));
			}
		}
		return warcaster;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Warcaster basicGetWarcaster() {
		return warcaster;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setWarcaster(Warcaster newWarcaster) {
		Warcaster oldWarcaster = warcaster;
		warcaster = newWarcaster;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WarmachineSystemPackage.TIER_LIST__WARCASTER, oldWarcaster, warcaster));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<TierLevel> getLevels() {
		if (levels == null) {
			levels = new EObjectContainmentEList<TierLevel>(TierLevel.class, this, WarmachineSystemPackage.TIER_LIST__LEVELS);
		}
		return levels;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<BaseUnit> getAllowedUnits() {
		if (allowedUnits == null) {
			allowedUnits = new EObjectResolvingEList<BaseUnit>(BaseUnit.class, this, WarmachineSystemPackage.TIER_LIST__ALLOWED_UNITS);
		}
		return allowedUnits;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case WarmachineSystemPackage.TIER_LIST__LEVELS:
				return ((InternalEList<?>)getLevels()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case WarmachineSystemPackage.TIER_LIST__WARCASTER:
				if (resolve) return getWarcaster();
				return basicGetWarcaster();
			case WarmachineSystemPackage.TIER_LIST__LEVELS:
				return getLevels();
			case WarmachineSystemPackage.TIER_LIST__ALLOWED_UNITS:
				return getAllowedUnits();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case WarmachineSystemPackage.TIER_LIST__WARCASTER:
				setWarcaster((Warcaster)newValue);
				return;
			case WarmachineSystemPackage.TIER_LIST__LEVELS:
				getLevels().clear();
				getLevels().addAll((Collection<? extends TierLevel>)newValue);
				return;
			case WarmachineSystemPackage.TIER_LIST__ALLOWED_UNITS:
				getAllowedUnits().clear();
				getAllowedUnits().addAll((Collection<? extends BaseUnit>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case WarmachineSystemPackage.TIER_LIST__WARCASTER:
				setWarcaster((Warcaster)null);
				return;
			case WarmachineSystemPackage.TIER_LIST__LEVELS:
				getLevels().clear();
				return;
			case WarmachineSystemPackage.TIER_LIST__ALLOWED_UNITS:
				getAllowedUnits().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case WarmachineSystemPackage.TIER_LIST__WARCASTER:
				return warcaster != null;
			case WarmachineSystemPackage.TIER_LIST__LEVELS:
				return levels != null && !levels.isEmpty();
			case WarmachineSystemPackage.TIER_LIST__ALLOWED_UNITS:
				return allowedUnits != null && !allowedUnits.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //TierListImpl
